package com.chen.demo.javase.annotaion.repeatable;

import java.lang.annotation.Annotation;
import java.util.Arrays;

/**
 * @author chenhongwei
 * <p>
 * <p>
 * java8 新增的@Repeatable注解，其实只是语法糖而已．
 * java8 注解的 {@link RepeatAnn} 类与 {@link Annotations}是等价的．
 * 新注解讲语法糖转化为注解值为数组形式．
 * @date 2019/10/3 14:57
 **/
public class Test {
    public static void main(String[] args) {
        Annotation[] annotations = RepeatAnn.class.getAnnotations();
        System.out.println(annotations.length);
        Arrays.stream(annotations).forEach(System.out::println);

        Annotation[] annotations2 = Annotations.class.getAnnotations();
        System.out.println(annotations2.length);
        Arrays.stream(annotations2).forEach(System.out::println);

    }

    @Role(name = "doctor")
    @Role(name = "who")
    public static class RepeatAnn {

    }

    @Roles({@Role(name = "doctor"),
            @Role(name = "who")})
    public static class Annotations {

    }
}
